//
//  BanBu_InviteFriendViewController.m
// Halfarea
//
//  Created by banbu3 on 14-6-16.
//
//

#import "BanBu_InviteFriendViewController.h"
#import "BanBu_AdressBookCell.h"
#import "BanBu_SendMessageViewController.h"

@interface BanBu_InviteFriendViewController ()

@end

@implementation BanBu_InviteFriendViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(id)initWithDataArray:(NSArray *)_data
{
    self = [super init];
    if (self) {
        self.dataArray = [[NSMutableArray alloc] initWithArray:_data];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = NSLocalizedString(@"myFriendTitle", nil);
//    _dataArray = [[NSMutableArray alloc] initWithCapacity:0];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *GridCellIdentifier = @"";
    BanBu_AdressBookCell *cell = [tableView dequeueReusableCellWithIdentifier:GridCellIdentifier];
    if(cell == nil)
    {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"BanBu_AdressBookCell" owner:nil options:nil] lastObject];
    }
    cell.detail = _dataArray[indexPath.row];
    
    return  cell;
}
#pragma mark UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = [NSDictionary dictionaryWithDictionary:_dataArray[indexPath.row]];
    BanBu_SendMessageViewController *mess = [[BanBu_SendMessageViewController alloc] initWithPersonData:dic];
    [self.navigationController pushViewController:mess animated:YES];
    [mess release];
}

@end
